package com.ruoyi.map.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.map.domain.FhMapWater;
import com.ruoyi.map.service.IFhMapWaterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 水域管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/map/water")
public class FhMapWaterController extends BaseController
{
    @Autowired
    private IFhMapWaterService fhMapWaterService;

    /**
     * 查询水域管理列表
     */
    @PreAuthorize("@ss.hasPermi('map:water:list')")
    @GetMapping("/list")
    public TableDataInfo list(FhMapWater fhMapWater)
    {
        startPage();
        List<FhMapWater> list = fhMapWaterService.selectFhMapWaterList(fhMapWater);
        return getDataTable(list);
    }

    /**
     * 导出水域管理列表
     */
    @PreAuthorize("@ss.hasPermi('map:water:export')")
    @Log(title = "水域管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhMapWater fhMapWater) throws IOException {
        List<FhMapWater> list = fhMapWaterService.selectFhMapWaterList(fhMapWater);
        ExcelUtil<FhMapWater> util = new ExcelUtil<FhMapWater>(FhMapWater.class);
        util.exportExcel(response, list, "水域管理数据");
    }

    /**
     * 获取水域管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('map:water:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fhMapWaterService.selectFhMapWaterById(id));
    }

    /**
     * 新增水域管理
     */
    @PreAuthorize("@ss.hasPermi('map:water:add')")
    @Log(title = "水域管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhMapWater fhMapWater)
    {
        return toAjax(fhMapWaterService.insertFhMapWater(fhMapWater));
    }

    /**
     * 修改水域管理
     */
    @PreAuthorize("@ss.hasPermi('map:water:edit')")
    @Log(title = "水域管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhMapWater fhMapWater)
    {
        return toAjax(fhMapWaterService.updateFhMapWater(fhMapWater));
    }

    /**
     * 删除水域管理
     */
    @PreAuthorize("@ss.hasPermi('map:water:remove')")
    @Log(title = "水域管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhMapWaterService.deleteFhMapWaterByIds(ids));
    }
}
